package redis

import (
	"context"
	"fmt"
)

func SyncGoodsStock(goodsId, goodsStock int) {
	key := fmt.Sprintf("goods_stock:goods_id_%d", goodsId)
	for i := 0; i < goodsStock; i++ {
		Rdb.RPush(context.Background(), key, goodsId)
	}

}
func GetGoodsStock(goodsId int) int64 {
	key := fmt.Sprintf("goods_stock:goods_id_%d", goodsId)
	return Rdb.LLen(context.Background(), key).Val()
}
func DelGoodsStock(goodsId, num int) {
	key := fmt.Sprintf("goods_stock:goods_id_%d", goodsId)
	for i := 0; i < num; i++ {
		Rdb.RPop(context.Background(), key)
	}
}
